package com.xinlu.wzgg.action;

import java.io.IOException;

import com.xinlu.derek.common.BaseAction;
import com.xinlu.derek.common.BaseForm;
import com.xinlu.persistence.Wzgg;
import com.xinlu.wzgg.bo.WzggBo;
import com.xinlu.wzgg.form.WzggForm;

public class WzggAction extends BaseAction {

	private WzggBo wzggBo;
	WzggForm fr = new WzggForm();

	public void setWzggBo(WzggBo wzggBo) {
		this.wzggBo = wzggBo;
	}

	public void setFr(WzggForm fr) {
		this.fr = fr;
	}

	@Override
	public String doExecute() throws Exception {
		return null;
	}

	@Override
	public void formInit() {
	}

	@Override
	public BaseForm getModel() {
		return fr;
	}

	/**
	 * 加载页面
	 * 
	 * @return
	 * @throws IOException
	 */
	public String loadPage() {

		Wzgg wzgg = wzggBo.loadWzgg();
		fr.setWzgg(wzgg);
		return "wzgg";
	}

	/**
	 * 加载网站公告
	 * 
	 * @return
	 * @throws IOException
	 */
	public String loadWzgg() throws IOException {

		Wzgg wzgg = wzggBo.loadWzgg();
		if (wzgg != null) {
			
			String ggnr = wzgg.getGgnr().length() > 20 ? (wzgg.getGgnr().substring(0, 20) + "...") : wzgg.getGgnr();

			getResponse().setCharacterEncoding("UTF-8");
			getResponse().getWriter().write(ggnr);
		}
		return null;
	}

}
